/*
 * @(#)EventQueryParasBuilder.java
 * Copyright (c) 2011 TravelSky Technology Ltd. All Right Reserved. 
 */
package com.meetingshow.privilege.service.util;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseQueryParasBuilder;
import com.meetingshow.privilege.service.model.EventQueryParas;

public class EventQueryParasBuilder extends BaseQueryParasBuilder {
    public static QueryStruct eventQueryBuilder(QueryStruct queryStruct, EventQueryParas eventQueryParas) throws Exception {
        builderInit(eventQueryParas, queryStruct);
        Map<String, Object> exactMap = queryStruct.getExactMap();
        Map<String, String> mistinessMap = queryStruct.getMistinessMap();
        
        if (StringUtils.isNotBlank(eventQueryParas.getEventId_e())) {
            exactMap.put(EventServiceParas.EVENTPO_EVENTID, Integer.valueOf(eventQueryParas.getEventId_e()));
        }
        if (StringUtils.isNotBlank(eventQueryParas.getEventType_e())) {
            exactMap.put(EventServiceParas.EVENTPO_EVENTTYPE, eventQueryParas.getEventType_e());
        }
        if (StringUtils.isNotBlank(eventQueryParas.getFromUserId_e())) {
            exactMap.put(EventServiceParas.EVENTPO_FROMUSERID, Integer.valueOf(eventQueryParas.getFromUserId_e()));
        }
        if (StringUtils.isNotBlank(eventQueryParas.getToUserId_e())) {
            exactMap.put(EventServiceParas.EVENTPO_TOUSERID, Integer.valueOf(eventQueryParas.getToUserId_e()));
        }
        if (StringUtils.isNotBlank(eventQueryParas.getToMeetingId_e())) {
            exactMap.put(EventServiceParas.EVENTPO_TOMEETINGID, Integer.valueOf(eventQueryParas.getToMeetingId_e()));
        }
        if (StringUtils.isNotBlank(eventQueryParas.getMeetingId_e())) {
            exactMap.put(EventServiceParas.EVENTPO_MEETINGID, Integer.valueOf(eventQueryParas.getMeetingId_e()));
        }
        pageBuilder(queryStruct, eventQueryParas);
        
        return queryStruct;
    }
}
